<template>
	<view>
		<uni-popup ref="popup_message" type="message">
			<uni-popup-message :type="message_type" :message="message" :duration="duration"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	
	export default {
		name: 'SelfPopupDialog',
		components:{
			uniPopup,
			uniPopupMessage,
			uniPopupDialog
		}
		,data() {
			return {
				message:"",
				message_type:"",
				duration:2000
			};
		}
		,methods:{
			open(message,message_type,duration,callback){
				// console.log(this.type);
				this.message = message;
				if(message_type!=undefined){
					this.message_type = message_type;
				}else{
					this.message_type = "success";
				}
				if(duration!=undefined){
					this.duration = 0;
					var that = this;
					setTimeout(function(){
						that.$refs["popup_message"].close();
						callback();
					},duration)
				}
				this.$refs["popup_message"].open();
			}
		}
	}
</script>

<style>

</style>
